package collection;

import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

/**
 * 测试Map.putAll是浅克隆还是深克隆
 */
public class MapTest {
    @Test
    public void test01(){
        HashMap<String,Object> map1 = new HashMap<>();
        map1.put("zhangsan",23);
        map1.put("lisi",24);
        map1.put("wangwu",25);

        HashMap<String,Object> map2 = new HashMap<>();
        map2.putAll(map1);

        map1.remove("lisi");

        System.out.println("====输出map1====");
        for(Map.Entry entry : map1.entrySet()){
            System.out.println(entry.getKey()+","+entry.getValue());
        }

        System.out.println("====输出map2====");
        for(Map.Entry entry : map2.entrySet()){
            System.out.println(entry.getKey()+","+entry.getValue());
        }

    }
}
